package com.ftg.learn.chapter02.mybatisinterface;

import com.ftg.learn.chapter02.util.MybatisUtil;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;
import java.util.List;
import java.util.Map;

/**
 * -
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/12/21 下午3:35
 */
public class TestDemo {

    public static void main(String[] args) {
        System.out.println(query());
    }

    /**
     * 查询所有
     * @return
     */
    public static List<Map<String, Object>> query() {

        MybatisUtil<SysUser> mybatisUtil = new MybatisUtil<>();
        SqlSession sqlSession = mybatisUtil.getSqlSession();

        try{
            SysUser sys = sqlSession.getMapper(SysUser.class);
            return sys.showAll();
        }catch (Exception e){
            e.printStackTrace();
            mybatisUtil.rollbackSession(sqlSession);
        }finally {
            mybatisUtil.closeSession(sqlSession);
        }
        return null;
    }

}
